import type { IFieldProps, IConfigProps } from '@/components/sofastui/AdvancedTable/interface'
import type { FormRule } from '@form-create/element-ui'

export const fields: IFieldProps[] = [
  {
    label: '组织名称',
    prop: 'name',
    minWidth: 60,
    import: true,
    export: true,
    search: true,
  },
  {
    label: '组织简称',
    prop: 'abbreviation',
    minWidth: 60,
    import: true,
    export: true,
    search: true,
  },
  {
    label: '组织编码',
    prop: 'code',
    minWidth: 60,
    import: true,
    export: true,
    search: true,
  },
  {
    label: '创建时间',
    prop: 'createdAt',
    minWidth: 60,
    import: true,
    export: true,
    search: true,
  },
  {
    label: '修改时间',
    prop: 'updatedAt',
    minWidth: 60,
    import: true,
    export: true,
    search: true,
  },
]

export const config: IConfigProps = {
  name: 'sysAreaTable',
  rowKey: 'id',
  url: '/api/sys/area',
  selection: true,
  add: true,
  delete: true,
  expand: true,
  showIndex: true,
  import: true,
  export: true,
  search: true,
  advancedSearch: true,
  refresh: true,
  settings: true,
}

export const formRules: FormRule[] = [
  {
    type: 'elCollapse',
    props: {
      modelValue: ['loginPageConfig'],
    },
    sync: ['modelValue'],
    style: {
      width: '100%',
    },
    children: [
      {
        type: 'elCollapseItem',
        props: {
          title: '登录页配置',
          name: 'loginPageConfig',
        },
        style: {
          paddingRight: '10px',
          paddingLeft: '10px',
        },
        children: [
          {
            type: 'checkbox',
            field: 'Loginmethod',
            title: '登陆方式',
            effect: {
              fetch: '',
            },
            $required: false,
            value: ['username'],
            options: [
              {
                label: '用户名',
                value: 'username',
              },
              {
                label: '短信',
                value: 'sms',
              },
              {
                label: '钉钉',
                value: 'dingding',
              },
              {
                label: '微信',
                value: 'wechat',
              },
            ],
            _fc_id: 'id_F7kwmcgfo6akb7c',
            name: 'ref_Fu3umcgfo6akb8c',
            display: true,
            hidden: false,
            _fc_drag_tag: 'checkbox',
          },
          {
            type: 'radio',
            field: 'allowRegistration',
            title: '允许注册',
            effect: {
              fetch: '',
            },
            $required: false,
            value: 1,
            options: [
              {
                label: '是',
                value: 1,
              },
              {
                label: '否',
                value: 0,
              },
            ],
            _fc_id: 'id_Ft08mcgfqljxboc',
            name: 'ref_Fxy6mcgfqljxbpc',
            display: true,
            hidden: false,
            _fc_drag_tag: 'radio',
          },
          {
            type: 'input',
            field: 'copyright',
            title: '版权声明',
            $required: false,
            _fc_id: 'id_Ftfnmcgfo05nb2c',
            name: 'ref_F09dmcgfo05nb3c',
            display: true,
            hidden: false,
            _fc_drag_tag: 'input',
          },
        ],
        _fc_id: 'id_Fclqmcgfnkbhazc',
        name: 'ref_Fmx1mcgfnkbhb0c',
        display: true,
        hidden: false,
        _fc_drag_tag: 'elCollapseItem',
      },
      {
        type: 'elCollapseItem',
        props: {
          title: '加密配置',
          name: 'jiamiConfig',
        },
        style: {
          paddingRight: '10px',
          paddingLeft: '10px',
        },
        children: [
          {
            type: 'radio',
            field: 'encryption',
            title: '加密方式',
            effect: {
              fetch: '',
            },
            $required: false,
            value: 'rsa',
            options: [
              {
                label: 'DES',
                value: 'des',
              },
              {
                label: 'RSA',
                value: 'rsa',
              },
              {
                label: 'MD5',
                value: 'md5',
              },
              {
                label: 'BAE64',
                value: 'base64',
              },
            ],
            _fc_id: 'id_F89jmcgfsonnckc',
            name: 'ref_Fclymcgfsonncoc',
            _fc_drag_tag: 'radio',
            display: true,
            hidden: false,
          },
          {
            type: 'input',
            field: 'encryptSaltValue',
            title: '加密盐值',
            $required: false,
            _fc_id: 'id_Fdirmcgfsonnclc',
            name: 'ref_Fmlomcgfsonncpc',
            _fc_drag_tag: 'input',
            display: true,
            hidden: false,
            computed: {
              hidden: {
                mode: 'OR',
                group: [
                  {
                    field: 'encryption',
                    condition: '==',
                    value: 'des',
                  },
                  {
                    field: 'encryption',
                    condition: '==',
                    value: 'rsa',
                  },
                ],
                invert: true,
              },
            },
          },
        ],
        _fc_id: 'id_F6fymcgfsonncmc',
        name: 'ref_Fzopmcgfsonncqc',
        _fc_drag_tag: 'elCollapseItem',
        display: true,
        hidden: false,
      },
      {
        type: 'elCollapseItem',
        props: {
          title: '密码重置配置',
          name: 'pswdResetConfig',
        },
        style: {
          paddingRight: '10px',
          paddingLeft: '10px',
        },
        children: [
          {
            type: 'checkbox',
            field: 'passwordResetMethod',
            title: '重置方式',
            effect: {
              fetch: '',
            },
            $required: false,
            value: [1, 2],
            options: [
              {
                label: '默认密码',
                value: 1,
              },
              {
                label: '随机密码',
                value: 2,
              },
              {
                label: '组合密码',
                value: 3,
              },
            ],
            _fc_id: 'id_Fhhrmcgft1qkcyc',
            name: 'ref_F6fdmcgft1qkczc',
            display: true,
            hidden: false,
            _fc_drag_tag: 'checkbox',
          },
          {
            type: 'input',
            field: 'defaultPassword',
            title: '默认密码',
            $required: false,
            _fc_id: 'id_F46smcgfr3rfbzc',
            name: 'ref_Fzeymcgfr3rfc3c',
            _fc_drag_tag: 'input',
            display: true,
            hidden: false,
            value: 'sofast@2026',
            computed: {
              hidden: {
                mode: 'AND',
                group: [
                  {
                    field: 'passwordResetMethod',
                    condition: 'on',
                    value: 1,
                  },
                ],
                invert: true,
              },
            },
          },
          {
            type: 'radio',
            field: 'randomPassword',
            title: '随机密码',
            effect: {
              fetch: '',
            },
            $required: false,
            value: 2,
            options: [
              {
                label: '低强度',
                value: 1,
              },
              {
                label: '中强度',
                value: 2,
              },
              {
                label: '高强度',
                value: 3,
              },
            ],
            _fc_id: 'id_Fc9wmcgg0uhedoc',
            name: 'ref_Fwggmcgg0uhedpc',
            _fc_drag_tag: 'radio',
            display: true,
            hidden: false,
            computed: {
              hidden: {
                mode: 'AND',
                group: [
                  {
                    field: 'passwordResetMethod',
                    condition: 'on',
                    value: 2,
                  },
                ],
                invert: true,
              },
            },
          },
          {
            type: 'radio',
            field: 'combinationPasswordType',
            title: '组合密码',
            effect: {
              fetch: '',
            },
            $required: false,
            options: [
              {
                label: '用户名+{固定值}',
                value: 1,
              },
              {
                label: '手机号后6位+{固定值}',
                value: 2,
              },
              {
                label: '身份证后6位+{固定值}',
                value: 3,
              },
            ],
            _fc_id: 'id_Fpovmcgg25b7e3c',
            name: 'ref_Fknzmcgg25b7e4c',
            _fc_drag_tag: 'radio',
            display: true,
            hidden: false,
            computed: {
              hidden: {
                mode: 'AND',
                group: [
                  {
                    field: 'passwordResetMethod',
                    condition: 'on',
                    value: 3,
                  },
                ],
                invert: true,
              },
            },
          },
          {
            type: 'input',
            field: 'combinationPassword',
            title: '组合密码固定值',
            $required: false,
            _fc_id: 'id_Fmtymcgg42x1eac',
            name: 'ref_Fy87mcgg42x1ebc',
            display: true,
            hidden: false,
            _fc_drag_tag: 'input',
            computed: {
              hidden: {
                mode: 'AND',
                group: [
                  {
                    field: 'passwordResetMethod',
                    condition: 'on',
                    value: 3,
                  },
                ],
                invert: true,
              },
            },
          },
          {
            type: 'radio',
            field: 'resetSuccessfulReminder',
            title: '重置成功提醒',
            effect: {
              fetch: '',
            },
            $required: false,
            value: 1,
            options: [
              {
                label: '是',
                value: 1,
              },
              {
                label: '否',
                value: 0,
              },
            ],
            _fc_id: 'id_Fztbmcgg62f9efc',
            name: 'ref_F3rwmcgg62f9egc',
            display: true,
            hidden: false,
            _fc_drag_tag: 'radio',
          },
          {
            type: 'checkbox',
            field: 'resetSuccessfulReminderMethod',
            title: '提醒方式',
            effect: {
              fetch: '',
            },
            $required: false,
            value: ['sys', 'sms', 'email'],
            options: [
              {
                label: '系统通知',
                value: 'sys',
              },
              {
                label: '短信',
                value: 'sms',
              },
              {
                label: '邮件',
                value: 'email',
              },
            ],
            _fc_id: 'id_Fa7umcgg6xp0ekc',
            name: 'ref_Fqwpmcgg6xp0elc',
            display: true,
            hidden: false,
            _fc_drag_tag: 'checkbox',
            computed: {
              hidden: {
                mode: 'AND',
                group: [
                  {
                    field: 'resetSuccessfulReminder',
                    condition: '==',
                    value: 1,
                  },
                ],
                invert: true,
              },
            },
          },
        ],
        _fc_id: 'id_F60nmcgfr3rfc0c',
        name: 'ref_Fk5cmcgfr3rfc4c',
        _fc_drag_tag: 'elCollapseItem',
        display: true,
        hidden: false,
      },
    ],
    _fc_id: 'id_Fbuemcgfnkbhawc',
    name: 'ref_Frz6mcgfnkbhaxc',
    display: true,
    hidden: false,
    _fc_drag_tag: 'elCollapse',
  },
]
